'use strict';var _Do=(t=>null==t?null:{filePath:t})(_Nw().file);let _Ph=!0;
if(_Do){let t=function(a,b,c,e){function l(...k){return new Proxy(()=>{},{get(f,g){f=[...k,g];var h=f.join(".");h=h in e?e[h]:b;if("function"===typeof h)return h(_Kg(a,...f));if(h)return l(...k,g);g=_Kg(a,...f);1<f.length&&"function"==typeof g&&(g=g.bind(_Kg(a,...f.slice(0,-1))));return g},set(f,g,h){[...k]},apply(f,g,h){}})}return l()},m={},u={},p,q,n,y=_wj(function*(){u=(yield _qf("customEntities"))||{}}),w=_wj(function*(a){m=a;yield y();n&&_Ph&&n.toggleClass("noContent",_Pt(m))}),z=_wj(function*(a){let [b,
c]=yield _Ya(_n(a,"text","GET",void 0,{"Cache-Control":"no-cache, no-store, max-age=0"}));return 200==c.status?{content:b}:{error:_1k(c.status,c)}}),A=_wj(function*(a){a=yield _hf._i(a,"text");a.error&&(a.error=yield _hf._fw(_r,+a.error));return a});_Do.filePath&&(p=_wj(function*(){p=null;let a=_0j(_Do.filePath)?yield A(_Do.filePath):yield z(_Do.filePath);if(a.error)q=a.error;else if(_Do.fileEncode=a.charEnc,a.content)try{yield w(JSON.parse(a.content))}catch(b){q="The format of the specified file is invalid."}}));
let B=a=>b=>{chrome.storage.local.set({["__dummy__"]:a},()=>{chrome.storage.local.get("__dummy__",c=>{chrome.storage.local.remove("__dummy__");b(c.__dummy__)})})},C=_Ow(400,()=>{n.addClass("unsaved").toggleClass("noContent",_Pt(m));_zj()()});_Vp=function(a){return t(a,!0,"CHROME",{tabs:null,windows:null,"runtime.id":null,"runtime.getManifest":null,"runtime.getURL":null,"runtime.lastError":()=>null,"extension.getViews":null,"extension.isAllowedFileSchemeAccess":null,"extension.isAllowedIncognitoAccess":null,
bookmarks:null,"storage.sync.QUOTA_BYTES":null,"storage.sync.getBytesInUse":null,"storage.local.get":()=>(b,c)=>{let e=()=>c(_9g({}.add(b,b?m.sc().keep(Object.keys(b)):m)));p?p()(e):setTimeout(e,0)},"storage.local.set":()=>(b,c)=>{let e=()=>{B(b)(l=>{m.add(l);n&&_Ph&&C();c&&c()})};p?p()(e):e()},"permissions.getAll":()=>b=>setTimeout(()=>b({permissions:["bookmarks","sessions","background","notifications","downloads"],origins:["<all_urls>"]}),0),"runtime.sendMessage":()=>(b,c,e)=>{e&&("ping"==c?_tl({toolbarBtns:{}},
l=>{(_Sy.indexOf(b)+"").in(Object.keys(l.toolbarBtns))?e("pong"):e()}):e())},"extension.getBackgroundPage":b=>()=>t(b(),!1,"BP",{"":"",_Ot:()=>u,_gy:()=>({}),_Ed:()=>!1,_Oe:!0,_4h:!0,_mg:!0,_0s:!0,_re:!0,_Td:!0,_Hi:!0,_3k:!0,_8w:!0,_sy:!0," ":""})})};let x=_wj(function*(a,b){_Ph=!1;const c=yield f=>_tl({trigActList:[],toolbarBtns:{},sections:[]},f);let e={},l=[];"new"==b&&(b=_8e(),c.sections.push({id:b,name:"Imported actions"}),e[b]=!0);for(let f of Object.keys(c.trigActList)){var k=c.trigActList[f];
if(~a.indexOf(f)){void 0===b?e[k.sctnId]=!0:k.sctnId=b;for(let [g,h]of _Rs(k.triggers))"eventId"==g&&(k=_3j(h),k.type==_Xs&&_d(k.num)&&l.push(k.num-_Y))}else delete c.trigActList[f]}yield f=>_Dd({trigActList:c.trigActList,sections:c.sections.filter(g=>e[g.id]),toolbarBtns:c.toolbarBtns.keep(l)},f);yield _Va();m.del("mouseGest","advOpts","userVars","joysticksOrder","previewMakerParams","scrtEdtr");_Gd(m);_Ph=!0});_Do.afterLoad=_wj(function*(){function a(){let d=q||!_Do.filePath?"New file":_Do.filePath.replace(/^.*[\/\\]/,
"");document.title=d+" - Settings File Editor";$(window.frameElement).triggerEvt("titleChange")}let b=!1,c=()=>_0j(_Do.filePath)?_Do.filePath.replace(/[^\\]+\.[^\\]+$/,""):"";const e=_wj(function*(d,r=m){if(!_Do.filePath||q||d){d=yield _Rp(_Pt(r)?c():!_Do.filePath||_0j(_Do.filePath)?_Do.filePath:_N(_Do.filePath),_0r,!0,_mh);if(!d)return!1;history.replaceState(null,"",location.pathname+"?file="+encodeURIComponent(d)+location.hash);_Do.filePath=d;q=null;n.find("> [type=text]").val(d);a()}let v;_0j(_Do.filePath)?
(r=yield _hf._ok(_Do.filePath,_uu(JSON.stringify(r),"UTF-8",!1)))&&(v=`Error while saving to the file. <hr b=2> "${_Do.filePath}" <hr b=2> ${yield _hf._fw(_r,+r)}`):v='Changes cannot be saved to an internet address. <hr b> Click on "Save as" in order to save to a local file.';if(v)return _gu(!b&&window.frameElement?window.parent:window)._yt(v,{type:"error"}),!1;n.removeClass("unsaved");return!0});let l=_Do.safeToClose=d=>{n.is(".unsaved")?_Yo("","Unsaved changes will be lost if you continue. <hr b=2> Discard changes?")(d):
d(!0)},k,f=d=>{k=!0;location.replace(d)};$(window).on("beforeunload",d=>{if(!k&&n.is(".unsaved"))return"Discard changes?"});window.frameElement&&$(window).captureTgtEvt("mousedown",()=>$(window.frameElement).triggerEvt("mousedown",!0));p&&(yield p());a();yield d=>_kd("file75.css",d);n=$(`\n <fileEditBar helpCtx=sttgFilEdt>\n <img src="/AutoCtrl/logo32.png" width=26>\n <h h=welcm sides=br></h>\n <l>Settings file:</l>\n ${_if("",q?"":_Do.filePath,"No file path specified","readonly")}\n <!--btn act=new>New file</btn><h h=new></h-->\n <btn act=open>Open</btn><h h=opn sides=brl></h>\n <btn act=save>Save</btn><h h=sav sides=brl></h>\n <btn act=savAs>Save as</btn><h h=savAs sides=brl></h>\n <btn act=dscrd>Discard</btn><h h=disrd sides=brl></h>\n <btn act=impAll>Import all</btn><h h=imAll sides=brl bublCls=sharpCorner></h>\n </fileEditBar>\n `).on("click",
"btn",_Et(function*(d){d=$(this).attr("act");if(!d.in("new","open","dscrd")||(yield l))switch(d){case "new":(yield e(!0,{}))&&f(location.pathname+location.search);break;case "open":(d=yield _Rp(c(),_0r))&&f(location.pathname+"?file="+encodeURIComponent(d));break;case "savAs":case "save":yield e("savAs"==d);break;case "dscrd":f("?file="+encodeURIComponent(_Do.filePath));break;case "impAll":(yield _Yo("","This will add the entire content of this settings file <br> to your AutoControl settings. <hr b=2> Continue?"))&&
_gp(yield r=>_tl(_dw,r))}})).appendTo(document.body);$(document.body).addClass("SFE_mode");let g=!0;var h=!0;if(null!=_Nw().storInit){let [d,r]=window.frameElement.storInit;yield w(d);yield x(r);g=yield e(!0);h=`The actions have been successfully saved to: <hr b=2> "${_Do.filePath}" <hr b=2> Do you want to review the file.`;h=g&&(yield _gu(window.parent)._Yo("",h,{icon:"success"}))}else _Do.filePath||(yield w({}));$("body > tabs").append("<perms><tit>Permissions <h h=prmLst></h></tit><cont></cont></perms>");
$(window.frameElement).triggerEvt({contentReady:h});q&&setTimeout(()=>_yt(`Error while opening the file. <hr b=2> "${_Do.filePath}" <hr b=2> ${q}`,{type:"error"}),300);_so("SFE_welcmShown",!0)||_uf(_Au.wait(),_Pi(50))(()=>$("[h=welcm]",n).triggerEvt({mousedown:!0}));b=!0;return g});let D=_wj(function*(a,b){const [c,e]=[_9g(m),_9g(u)];yield x(a,b);a=yield l=>_tl(_dw,l);[m,u]=[c,e];return a});var _ut=_Et(function*(a,b){a=a.get().map(c=>$(c).attr("actionId"));a=yield D(a,b);_gp(a,"new"!=b,!0,!0,!1,!1)})};
